import request from "@/utils/request";

// 查询积分列表
export function listIntegral(query) {
  return request({
    url: "/shop/integral/list",
    method: "get",
    params: query,
  });
}

// 查询积分详细
export function getIntegral(integralId) {
  return request({
    url: "/shop/integral/" + integralId,
    method: "get",
  });
}

// 新增积分
export function addIntegral(data) {
  return request({
    url: "/shop/integral",
    method: "post",
    data: data,
  });
}

// 修改积分
export function updateIntegral(data) {
  return request({
    url: "/shop/integral",
    method: "put",
    data: data,
  });
}

// 删除积分
export function delIntegral(integralId) {
  return request({
    url: "/shop/integral/" + integralId,
    method: "delete",
  });
}

// 使用积分兑换优惠券
export function exchangeCoupon(
  userId,
  shopId,
  couponIds,
  couponNeedIntegral,
  integralNum
) {
  const data = {
    userId: userId,
    shopId:shopId,
    couponIds: couponIds,
    couponNeedIntegral: couponNeedIntegral,
    integralNum: integralNum,
  };
  console.log(couponNeedIntegral)
  return request({
    url: "/shop/integral/exchangeCoupon",
    method: "post",
    data:data,
  });
}
